<?php
$profileId=$_SESSION['profileid'];
$startDate;
$endDate;

?>
<div class = "row" >
<?php
$SHParams = array(
      'dimensions' => 'ga:hour',
      
      'sort' => '-ga:sessions');
$resultsSH = $analytics->data_ga->get(
       'ga:' . $profileId,
       '2014-12-12',
       '2014-12-12',
	   'ga:sessions',
       $SHParams
	   );
?>
<script type="text/javascript">
            var chartData = [
		<?php
    // Print table rows.
		$x=1;
		foreach ($resultsSH->getRows() as $row) {
      
		?>
		{
			"hour": "<?php echo $row[0]; ?>",
			"visits": <?php echo $row[1]; ?>
		}
		<?php
		if($x>=sizeof($resultsSH->getRows()))
		{
		?>
		<?php
		}
		else
		{
		?>
		,
		<?php
		}
		$x++;
     
		}
		?>
		];
</script>

</div>	   


<script src="amcharts/amcharts.js" type="text/javascript"></script>
  <script src="amcharts/serial.js" type="text/javascript"></script>

        <script type="text/javascript">
            var chart;

            AmCharts.ready(function () {
                // SERIAL CHART
                chart = new AmCharts.AmSerialChart();
                chart.dataProvider = chartData;
                chart.categoryField = "hour";
                chart.startDuration = 1;

                // AXES
                // category
                var categoryAxis = chart.categoryAxis;
                categoryAxis.labelRotation = 90;
                categoryAxis.gridPosition = "start";

                // value
                // in case you don't want to change default settings of value axis,
                // you don't need to create it, as one value axis is created automatically.

                // GRAPH
                var graph = new AmCharts.AmGraph();
                graph.valueField = "visits";
                graph.balloonText = "[[category]]: <b>[[value]]</b>";
                graph.type = "column";
                graph.lineAlpha = 0;
                graph.fillAlphas = 0.8;
                chart.addGraph(graph);

                // CURSOR
                var chartCursor = new AmCharts.ChartCursor();
                chartCursor.cursorAlpha = 0;
                chartCursor.zoomable = false;
                chartCursor.categoryBalloonEnabled = false;
                chart.addChartCursor(chartCursor);

                chart.creditsPosition = "top-right";

                chart.write("chart");
            });
        </script>


<div class = "row" >

<div id="chart" style="width: 100%; height: 400px;"></div>
</div>
